<?php

if(!isset($_GET["date"])){
     $time = time();
}else{
    $time= strtotime($_GET["date"]);
}
$dates = [];
$mydir = dir(__DIR__.'/data');
//从目录句柄中读取条目
while($file = $mydir->read()) {
    if ($file != "." && $file != "..") {
        if (preg_match("/sars-(.*)\.json/i", $file,$match)) {
            $dates[] = $match[1];
        }
    }

}
$datapath = "/sars/data/sars-".date('Y-m-d',$time).".json";
$now = date('Y-m-d',$time);
?>
<style>
    * {
        margin: 0;
        padding: 0
    }

    html, body {
        width: 100%;
        height: 100%;
    }

    #main {
        width: 600px;
        height: 600px;
        margin: 20px auto;
        border: 1px solid #ddd;
    }

    /*默认长宽比0.75*/
</style>

<a href="sars.php">确诊</a>
<a href="sars_suspected.php">疑似</a>
<a href="sars_cursed.php">治愈</a>
<a href="sars_dead.php">死亡</a>
<a href="sars_yesterday_comfirm.php">昨日确诊</a>
<a href="sars_yesterday_cursed.php">昨日治愈</a>
<a href="sars_yesterday_dead.php">昨日死亡</a>
<a href="sars_yesterday_suspected.php">昨日疑似</a>
<a href="sars_yesterday_dead_apr.php">昨日死亡/(昨日死亡+昨日治愈)</a>


<a href="sars_dead_apr.php">病死率</a>
<a href="sars_dead_all_apr.php">死亡/(死亡+治愈)</a>
<a href="sars_increased_apr.php">确诊增长率</a>
<a href="sars_increased_apr.php">确诊增长率</a>
<form method="get" action="">
    <select name="date">
        <?php

        foreach ($dates as $date){
            ?>
            <option value="<?=$date ?>" <?php if($now == $date){echo 'selected';} ?> > <?=$date ?></option>

        <?php }?>
    </select>
    <button type="submit"> 提交</button>
</form>
<br>
<br>
<a href="update.php">更新数据</a>


<br>